package com.ykt.model;

import com.jfinal.plugin.activerecord.Page;

import java.util.List;
import java.util.Map;

public class GoodsCategory extends BaseModel<GoodsCategory> {
	private static final long serialVersionUID = 1L;

	public static final String name = "name";
    public static final String shop_id = "shop_id";
    public static final String icon = "icon";

    public static final GoodsCategory dao = new GoodsCategory();

    @Override
    public Page<GoodsCategory> paginate(int pageNumber, int rows, Map<String, String> paramMap) {
        String select = "SELECT c.*, s.name shopName ";
        String exceptSelect = " FROM goods_category c left join shop s on c.shop_id=s.id";

        return this.paginate(select, exceptSelect, pageNumber, rows, paramMap);
    }

    public List<GoodsCategory> findByShopId(Integer shopId) {
        String sql = "SELECT * FROM goods_category c WHERE shop_id=? ";

        return dao.find(sql, shopId);
    }
}
